<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8" import="sdfi.lee.Entity.News"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="sdfi.lee.DAO.NewsDAO"%>
<%@page import="java.util.List" %>
<html>
<head>
<script type="text/javascript" src="<c:url value="/js/jquery-1.6.js"></c:url>"></script>
<script type="text/javascript" src="<c:url value="/js/jquery.form.js"></c:url>"></script>
<script type="text/javascript">
	
	$(function(){
	
		$('#checkall').click(function(){
			$('td>:checkbox').attr('checked',$(this).is(':checked'));
			$(this).prev().html($(this).is(':checked')?"取消":"全选");
		});
		$('#deletenews').click(function(){
			var d=$('form td>:checkbox').fieldSerialize();
			if(d.length<=0){ alert('请选择要删除新闻');return;}
			var options={
			url:'../newspicdel.html',
			dateType:'text',
			data:d,
			success:function(data,status){
				$('tr:has(:checked)').remove();
				if($('table tr').size()<2) $("#deletenews").attr("disabled",true);
				}
			}
			$.ajax(options);
			
		});
		$("#newstype").change(function(){
			var url=$(this).attr("url")+"&ntype="+$(this).val();
			$("#f").attr("action",url).submit();
			
		});
		
	});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="<c:url value='/css/common.css'></c:url>">
<link rel="stylesheet" href="<c:url value='/css/adnews.css'></c:url>" />

<title>新闻管理</title>
</head>
<body>
<%
NewsDAO dao=new NewsDAO();
List<News> list=null;
	if(null==request.getParameter("ntype"))
		 	 list=dao.getAllNew(Integer.valueOf(request.getParameter("pg")).intValue(),0,15);
	else
	list=dao.getAllNew(new Integer(request.getParameter("pg")).intValue(),new Integer(request.getParameter("ntype")).intValue(),15);
//	System.out.println(request.getParameter("ntype"));
 //	System.out.println(request.getParameter("pg"));
	if(null!=list&&list.size()>0) 
	{
		
		request.setAttribute("list",list);
%>
<div class="contain">
	<form id="f" method="post"  action="">
	<table cellpadding="0" cellspacing="0"> 
		<tr>
			<th style="width:15%">
				<span>全选</span><input type="checkbox" id="checkall">
			</th>
			<th style="width:55%">
				新闻标题
			</th>
			<th style="width:15%">
				新闻类型
			</th>
			
			<th style="width:15%">
				管理
			</th>
		</tr>
		
		<c:forEach items="${requestScope.list}" var="new">
			<tr>
			<td>
				<input type="checkbox" value="${new.id}" name="newsids">
			</td>
			<td>${fn:substring(new.newstitle,0,20)}...
			</td>
			<td>
				<c:if test="${new.newstype==1}">中心动态</c:if>
				<c:if test="${new.newstype==2}">业界动态</c:if>
				<c:if test="${new.newstype==3}">合作交流</c:if>
				<c:if test="${new.newstype==4}">发展规划</c:if>
				<c:if test="${new.newstype==5}">服务指南</c:if>
				<c:if test="${new.newstype==6}">人才招聘</c:if>
				<c:if test="${new.newstype==7 }">图片新闻</c:if>
				<c:if test="${new.newstype==8 }">政策法规</c:if>
			</td>
		
			<td >
			<c:url value='/admin/newsmf.jsp' var="newurl">
				<c:param name="newsid" value='${new.id}'></c:param>
			</c:url>
				<a href="${newurl}">修改</a>
			</td>
		</c:forEach>
		<tr>
			<td colspan="4" style="text-align:left"><input type="button" value="删除新闻" id="deletenews">
			
				<label>新闻选择：</label><select id="newstype"  url=<c:url value='/admin/newsmg.jsp?pg=${param.pg}'/>>
						<option value="1"  >中心动态</option>
						<option value="2">业界动态</option>
						<option value="3">合作交流</option>
						<option value="4">发展规划</option>
						<option value="5">服务指南</option>
						<option value="6">人才招聘</option>
						<option value="7">图片新闻</option>
						<option value="8">政策法规</option>
					</select>
					
			</td>
		</tr>
		
	</table>
	
	</form>
		<c:url var="up" value="/admin/newsmg.jsp"><c:param name="ntype" value="${param.ntype}"></c:param>
			<c:param name="pg" value="${param.pg-1}"></c:param>
		</c:url>
		<c:url var="down" value="/admin/newsmg.jsp"><c:param name="ntype" value="${param.ntype}"></c:param>
			<c:param name="pg" value="${param.pg+1}"></c:param>
		</c:url>
	<div id="pages" style="text-align:center">
			<font>
				<c:if test="${param.pg==1}">&lt;</c:if>
				<c:if test="${param.pg!=1}"><a href="${up}">&lt;</a></c:if>
			</font>
			<font>
				${param.pg}
			</font>
			<font>
				<c:choose>
					<c:when test="${fn:length(requestScope.list)<15}">&gt;</c:when>
					<c:otherwise><a href="${down}">&gt;</a></c:otherwise>
				</c:choose>
			</font>
		
	</div>
</div>


<%
	}
%>

</body>
</html>